(function() { "use strict";
/**
 * Config for the router
 */
app.config(configBlocks);

function configBlocks($stateProvider) {
    $stateProvider
        // dashboard
        .state("app", {
            abstract: true,
            url: "/app",
            templateUrl: "views/app.html"
        })

        .state("app.dashboard", {
            url: "/dashboard",
            templateUrl: "views/app_dashboard.html",
            resolve: {
                deps: function($ocLazyLoad) {
                    return $ocLazyLoad.load(["scripts/controllers/chart.js"]);
                }
            }
        })

        .state("app.tasks", {
            url: "/tasks",
            templateUrl: "views/app_tasks.html",
            resolve: {
            }
        })

        .state("app.about", {
            url: "/about",
            templateUrl: "views/app_about.html",
            resolve: {
            }
        })
        
        .state("app.develop_buttons", {
            url: "/develop_buttons",
            templateUrl: "views/develop/ui_buttons.html",
            resolve: {
            }
        })
        .state("app.develop_icons", {
            url: "/develop_icons",
            templateUrl: "views/develop/ui_icons.html",
            resolve: {
            }
        })
        .state("app.develop_grid", {
            url: "/develop_grid",
            templateUrl: "views/develop/ui_grid.html",
            resolve: {
            }
        })
        .state("app.develop_toaster", {
            url: "/develop_toaster",
            templateUrl: "views/develop/ui_toaster.html",
            resolve: {
                deps: function($ocLazyLoad) {
                    return $ocLazyLoad.load(["scripts/controllers/develop_toaster.js"]);
                }
            }
        })

        // process
        .state("app.process", {
            url: "/process",
            cache: false,
            template: "<div ui-view></div>"
        })
        .state("app.process.patcase", {
            url: "/patcase",
            templateUrl: "views/work/process_patcase.html",
            cache: false,
            resolve: {
                deps: function(uiLoad, $rootScope) {
                    return uiLoad.load([
                        "scripts/controllers/process_patcase.js",
                        "scripts/controllers/basic_servreq.js"
                    ]).then(function(){
                        $rootScope.filterStatus = "all";
                    });
                }
            }
        })
        .state("app.process.service", {
            url: "/service?service_Id&status",
            templateUrl:"views/work/process_service.html",
            cache: false,
            resolve: {
                deps: function (uiLoad, $rootScope) {
                    return uiLoad.load([
                        "scripts/controllers/process_service.js",
                        "scripts/controllers/basic_servreq.js",
                        "scripts/controllers/process_patcase.js"
                    ]).then(function(){
                        $rootScope.filterStatus = "all";
                    });
                }
            }
        })

        .state("app.process.selectPatient", {
            url: "/selectPatient?service_Id",
            templateUrl: "views/work/process_service_selectpatient.html",
            cache: false,
            resolve: {
                deps: function(uiLoad, $rootScope) {
                    return uiLoad.load([
                        "scripts/controllers/process_service.js",
                        "scripts/controllers/basic_servreq.js"
                    ]).then(function() {
                        $rootScope.filterStatus = "all";
                    });
                }
            }
        })

        .state("app.process.serviceCreate", {
            url: "/serviceCreate?patient_Id&service_Id",
            templateUrl: "views/work/process_service_create.html",
            cache: false,
            resolve: {
                deps: function(uiLoad, $rootScope) {
                    return uiLoad.load([
                        "scripts/controllers/process_service.js",
                        "scripts/controllers/process_patcase.js"
                    ]).then(function() {
                        $rootScope.filterStatus = "all";
                    });
                }
            }
        })

        .state("app.process.pay", {
            url: "/pay?servReq_Id",
            templateUrl: "views/work/process_pay.html",
            cache: false,
            resolve: {
                desp: function(uiLoad) {
                    return uiLoad.load([
                        "scripts/controllers/process_service.js"
                    ])
                }
            }
        })

        .state("app.process.viewreport", {
            url: "/viewreport?servReq_Id",
            templateUrl: "views/work/process_service_viewreport.html",
            cache: false,
            resolve: {
                desp: function(uiLoad){
                    return uiLoad.load([
                        "script/controllers/process_service.js"
                    ])
                }
            }
        })

        .state("app.process.wechat", {
            url: "/wechat?servReq_Id",
            templateUrl: "views/work/process_pay_wechat.html",
            cache: false,
            resolve: {
                desp: function(uiLoad){
                    return uiLoad.load([
                        "script/controllers/process_service.js"
                    ])
                }
            }
        })

        .state("app.process.search", {
            url: "/search",
            templateUrl: "views/work/process_search.html",
            cache: false,
            resolve: {
                deps: function(uiLoad, $rootScope) {
                    return uiLoad.load([
                        "scripts/controllers/process_patcase.js",
                        "scripts/controllers/basic_servreq.js"
                    ]).then(function() {
                        $rootScope.filterStatus = "all";
                    });
                }
            }
        })
        .state("app.process.filter", {
            url: "/filter",
            templateUrl: "views/work/process_selection.html",
            cache: false,
            resolve: {
                deps: function(uiLoad, $rootScope) {
                    return uiLoad.load([
                        "scripts/controllers/process_patcase.js",
                        "scripts/controllers/basic_servreq.js"
                    ]).then(function(){
                        $rootScope.filterStatus = "initial";
                    });
                }
            }
        })
        .state("app.process.diagnosis", {
            url: "/diagnosis",
            templateUrl: "views/work/process_diagnosis.html",
            cache: false,
            resolve: {
                deps: function(uiLoad, $rootScope) {
                    return uiLoad.load([
                        "scripts/controllers/process_diagnosis.js",
                        "scripts/controllers/basic_servreq.js"
                    ]).then(function(){
                        $rootScope.filterStatus = "needdiag";
                    });
                }
            }
        })
        .state("app.process.accumulation", {
            url: "/accumulation",
            templateUrl: "views/work/process_accumulation.html",
            cache: false,
            resolve: {
                deps: function(uiLoad) {
                    return uiLoad.load([
                        "scripts/controllers/process_accumulation.js",
                        "scripts/controllers/basic_hospital.js",
                        "scripts/controllers/basic_servreq.js"
                    ]);
                }
            }
        })
        .state("app.process.paymentOperation", {
            url: "/paymentOperation",
            templateUrl: "views/work/process_paymentoperation.html",
            cache: false,
            resolve: {
                deps: function(uiLoad) {
                    return uiLoad.load([
                        "scripts/controllers/process_paymentoperation.js",
                        "scripts/controllers/basic_servreq.js"
                    ]);
                }
            }
        })
        .state("app.process.paymentPlatform", {
            url: "/paymentPlatform",
            templateUrl: "views/work/process_paymentplatform.html",
            cache: false,
            resolve: {
                deps: function(uiLoad) {
                    return uiLoad.load([
                        "scripts/controllers/process_paymentplatform.js",
                        "scripts/controllers/basic_servreq.js"
                    ]);
                }
            }
        })
        .state("app.process.finish", {
            url: "/finish",
            templateUrl: "views/work/process_finish.html",
            cache: false,
            resolve: {
                deps: function(uiLoad) {
                    return uiLoad.load([
                        "scripts/controllers/process_finish.js",
                        "scripts/controllers/process_evaluation.js",
                        "scripts/controllers/basic_servreq.js"
                    ]);
                }
            }
        })
        .state("app.process.operation", {
            url: "/operation",
            templateUrl: "views/work/process_operation.html",
            cache: false
        })
        .state("app.process.operation.businessmanager", {
            url: "/businessmanager",
            cache: false,
            resolve: {
                deps: function(uiLoad) {
                    return uiLoad.load([
                        "scripts/controllers/process_operation.js",
                        "scripts/controllers/basic_servreq.js"
                    ]);
                }
            }
        })
        .state("app.process.operation.operator", {
            url: "/operator",
            cache: false,
            resolve: {
                deps: function(uiLoad) {
                    return uiLoad.load([
                        "scripts/controllers/process_operation.js",
                        "scripts/controllers/basic_servreq.js"
                    ]);
                }
            }
        })
        .state("app.process.operation.doctor", {
            url: "/doctor",
            cache: false,
            resolve: {
                deps: function(uiLoad) {
                    return uiLoad.load([
                        "scripts/controllers/process_operation.js",
                        "scripts/controllers/basic_servreq.js"
                    ]);
                }
            }
        })
        .state("app.process.operation.medicaladmin", {
            url: "/medicaladmin",
            cache: false,
            resolve: {
                deps: function(uiLoad) {
                    return uiLoad.load([
                        "scripts/controllers/process_operation.js",
                        "scripts/controllers/basic_servreq.js"
                    ]);
                }
            }
        })

        // basic
        .state("app.basic", {
            url: "/basic",
            template: "<div ui-view></div>"
        })
        .state("app.basic.patient", {
            url: "/patient",
            templateUrl: "views/work/basic_patient.html",
            resolve: {
                deps: function(uiLoad) {
                    return uiLoad.load("scripts/controllers/basic_patient.js");
                }
            }
        })
        .state("app.basic.doctor", {
            url: "/doctor",
            templateUrl: "views/work/basic_doctor.html"
        })
        .state("app.basic.hospital", {
            url: "/hospital/:filterOpe",
            templateUrl: "views/work/basic_hospital.html",
            resolve: {
                deps: function(uiLoad) {
                    return uiLoad.load("scripts/controllers/basic_hospital.js");
                }
            }
        })

        .state("app.basic.location", {
            url: "/location",
            templateUrl: "views/work/basic_location.html",
            resolve: {
                deps: function(uiLoad) {
                    return uiLoad.load("scripts/controllers/basic_location.js");
                }
            }
        })

		// query
        .state("app.query", {
            url: "/query",
            template: "<div ui-view></div>"
        })
        .state("app.query.opecentime", {
            url: "/opecentime",
            templateUrl: "views/work/query_opecentime.html",
            resolve: {
		        deps: function(uiLoad) {
		            return uiLoad.load([
		                "scripts/controllers/query_opecentime.js",
		                "scripts/controllers/basic_servreq.js"
		            ]);
		        }
            }
        })
        .state("app.query.servreqs", {
            url: "/servreqs?like",
            templateUrl: "views/work/query_servreqs.html",
            resolve: {
                deps: function(uiLoad) {
                    return uiLoad.load("scripts/controllers/basic_servreq.js");
                }
            }
        })
        .state("app.query.payment", {
            url: "/query_payment",
            templateUrl: "views/work/query_payment.html",
            resolve: {
                deps: function(uiLoad) {
                    return uiLoad.load("scripts/controllers/query_payment.js");
                }
            }
        })
        .state("app.query.feedetails", {
            url: "/query_feedetails",
            templateUrl: "views/work/query_feedetails.html",
            resolve: {
                deps: function(uiLoad) {
                    return uiLoad.load("scripts/controllers/query_feedetails.js");
                }
            }
        })
		.state("app.query.surgery", {
            url: "/query_surgery",
            templateUrl: "views/work/query_surgery.html",
            resolve: {
                deps: function(uiLoad) {
                    return uiLoad.load("scripts/controllers/query_surgery.js");
                }
            }
        })
        .state("app.query.feesummary", {
            url: "/query_feesummary",
            templateUrl: "views/work/query_feesummary.html",
            resolve: {
                deps: function(uiLoad) {
                    return uiLoad.load("scripts/controllers/query_feesummary.js");
                }
            }
        })
		.state("app.query.paymentPlatform", {
            url: "/query_paymentPlatform",
            templateUrl: "views/work/query_paymentplatform.html",
            resolve: {
                deps: function(uiLoad) {
                    return uiLoad.load("scripts/controllers/query_paymentplatform.js");
                }
            }
        })
        
        // analysis
        .state("app.analysis", {
            url: "/analysis",
            cache:false,
            template: "<div ui-view></div>"
        })
        .state("app.analysis.login", {
            url: "/analysis_login",
            templateUrl: "views/work/analysis_login.html",
            cache:false,
            resolve: {
                deps: function(uiLoad) {
                    return uiLoad.load("scripts/controllers/analysis_login.js");
                }
            }
        })
        
        // lab
        .state("app.lab", {
            url: "/lab",
            cache:false,
            template: "<div ui-view></div>"
        })
        .state("app.lab.graph", {
            url: "/lab_graph",
            templateUrl: "views/work/lab_graph.html",
            resolve: {
                deps: function(uiLoad) {
                    return uiLoad.load("scripts/controllers/chart.js");
                }
            }
        })
        .state("app.lab.process", {
            url: "/lab_process",
            templateUrl: "views/work/analysis_process.html",
            resolve: {
                deps: function(uiLoad) {
                    return uiLoad.load("scripts/controllers/analysis_process.js");
                }
            }
        })
        .state("app.lab.reporter", {
            url: "/lab_reporter",
            templateUrl: "views/work/lab_reporter.html",
            resolve: {
                deps: function(uiLoad) {
                }
            }
        })
        .state("app.lab.fileupload", {
            url: "/lab_fileupload",
            templateUrl: "views/work/lab_fileupload.html",
            resolve: {
                deps: ['$ocLazyLoad',
                  function( $ocLazyLoad){
                    return $ocLazyLoad.load('angularFileUpload').then(
                        function(){
                           return $ocLazyLoad.load('scripts/controllers/file-upload.js');
                        }
                    );
                }]
            }
        })

        

        // system
        .state("app.system", {
            url: "/system",
            template: "<div ui-view></div>"
        })
        
        .state("app.system.user", {
            url: "/user",
            templateUrl: "views/system/user.html",
            resolve: {
                deps: function(uiLoad) {
                    return uiLoad.load("scripts/controllers/system_user.js");
                }
            }
        })

        .state("app.system.userofme", {
            url: "/userofme",
            templateUrl: "views/system/userofme.html",
            resolve: {
                deps: function(uiLoad) {
                    return uiLoad.load("scripts/controllers/system_user.js");
                }
            }
        })
        
        .state("app.system.notifications", {
            url: "/notifications",
            templateUrl: "views/system/notifications_list.html"
        })

        // page
        .state("app.page", {
            url: "/page",
            template: '<div ui-view class="fade-in-down"></div>'
        })
        .state("app.page.profile", {
            url: "/profile",
            templateUrl: "views/app_profile.html",
            resolve: {
                deps: function(uiLoad) {
                    return uiLoad.load(["scripts/controllers/profile.js"]);
                }
            }
        })
        .state("app.page.updatepwd", {
            url: "/updatepwd",
            templateUrl: "views/app_updatepwd.html",
            resolve: {
                deps: function(uiLoad) {
                    return uiLoad.load(["scripts/controllers/profile.js"]);
                }
            }
        })
        // others
        .state("lockme", {
            url: "/lockme",
            templateUrl: "views/app_lockme.html"
        })
        
        .state("go", {
            url: "/go?sref&params&access_token",
            templateUrl: "views/app_go.html",
            cache: false,
            resolve: {
                deps: function($ocLazyLoad) {
                    return $ocLazyLoad.load(["scripts/controllers/go.js"]);
                }
            }
        })

        .state("evaluation", {
            url:"/evaluation?servReq_Id&external_token",
            templateUrl: "views/work/process_evaluation.html",
            resolve: {
                deps: ["uiLoad", function (uiLoad) {
                    return uiLoad.load([
                        "scripts/controllers/process_evaluation.js"
                    ])
                }]
            }
        })

        .state("access", {
            url: "/access",
            template: '<div ui-view class="fade-in-right-big smooth"></div>'
        })
        .state("access.login", {
            url: "/login",
            templateUrl: "views/app_login.html",
            resolve: {
                deps: ["uiLoad", function(uiLoad) {
                    return uiLoad.load(["scripts/controllers/login.js"]);
                }]
            }
        })
        .state("access.signup", {
            url: "/signup",
            templateUrl: "views/app_signup.html",
            resolve: {
                deps: function(uiLoad) {
                    return uiLoad.load(["scripts/controllers/signup.js"]);
                }
            }
        })
        .state("access.signok", {
            url: "/signok",
            templateUrl: "views/app_signok.html",
            resolve: {
                deps: function(uiLoad) {
                    return uiLoad.load(["scripts/controllers/signok.js"]);
                }
            }
        })
        .state("access.forgotpwd", {
            url: "/forgotpwd",
            templateUrl: "views/app_forgotpwd.html",
            resolve: {
                deps: function(uiLoad) {
                    return uiLoad.load(["scripts/controllers/app_forgotpwd.js"]);
                }
            }
        })
        .state("access.404", {
            url: "/404",
            templateUrl: "views/app_404.html"
        })
}

})();